<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JavaScript Math（算数） 对象-round()</title>
</head>

<body>
    <!-- Math（算数）对象的作用是：执行常见的算数任务。 -->

    <p id="demo">单击按钮舍入与“2.5”最接近的整数</p>
    <button onclick="myFunction()">点我</button>
    <script>
        function myFunction() {
            document.getElementById("demo").innerHTML = Math.round(2.5);
        }
    </script>
</body>

</html>